 <template>
    <div>
        <div class="e-form">
            <BillTop  @cancel="handleClose"></BillTop>
            <div class="tabs" style="margin-bottom: 120px">
                <div class="tabs-title">基本信息</div>
                <div style="width: 100%" class="form">
                    <el-form :model="basicForm" :label-width="formLabelWidth">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="变更编号：">
                                    <span>{{ basicForm.billNo	 }}</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                               <el-form-item label="调动编号：">
                                    <span>{{ basicForm.parentNo }}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="变更日期：">

                                     <el-date-picker
                                            value-format="yyyy-MM-dd"
                                            :clearable="false"
                                            type="date"
                                            placeholder="选择日期"
                                            v-model="basicForm.changedDate"
                                        ></el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                               <el-form-item label="机构：">
                                    <span>{{ basicForm.orgName }}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="调入机构：">
                                    <span>
                                        {{
                                            basicForm.transferInOrgName
                                        }}
                                    </span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                               <el-form-item label="接收人员：">
                                     <span>
                                        {{
                                            basicForm.receiverName
                                        }}
                                    </span>

                                </el-form-item>
                            </el-col>
                        </el-row>

                        <el-row>
                            <el-col :span="12">
                                 <el-form-item label="不含税租赁金额（元）：">
                                   <span>
                                       {{basicForm.rmbNotTaxprice}}
                                   </span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">

                                    <el-form-item label="经办人员：">
                                 <span>
                                       {{basicForm.operatorName}}

                                   </span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                 <el-form-item label="税率%：">
                                   <el-input v-model="basicForm.taxRate"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">

                                    <el-form-item label="税额：">
                                                                   <el-input v-model="basicForm.taxAmount"></el-input>

                                </el-form-item>
                            </el-col>
                        </el-row>
                          <el-row>
                            <el-col :span="12">
                                 <el-form-item label="原税价合计（元）：">
                                   <span>
                                       {{basicForm.baseCurNotTaxprice}}
                                   </span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">

                                    <el-form-item label="状态：">
                                 <span>
                                       {{stateArr[basicForm.state]}}
                                   </span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                         <el-row>
                            <el-col :span="12">
                                <el-form-item label="变更后税价合计（元）：">
                                    <span>{{ basicForm.changedTotalMoney }}</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="人民币汇率：">
                                    <span>{{
                                        basicForm.rmbRate
                                    }}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="币种：">

                                    <span>
                                        {{
                                            basicForm.currency
                                        }}
                                    </span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="变更期数：">
                                    <span>{{ basicForm.period }}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>

                           <el-row>
                            <el-col :span="24">
                                <el-form-item label="备注：">
                                    <el-input
                                        type="textarea"
                                        v-model="basicForm.remarks"
                                        autocomplete="off"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="本位币：">
                                    <span>{{ basicForm.baseCurName }}</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="本位币汇率：">
                                    <span>{{
                                        basicForm.baseCurRate
                                    }}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>

  <el-row>
                            <el-col :span="12">
                                <el-form-item label="不含税租赁金额（本位币）：">
                                    <span>
                                        {{
                                            basicForm.baseCurNotTaxprice
                                        }}
                                    </span>

                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </div>
            <div class="buttons">

                <el-button
                    type="primary"
                    size="small"
                    style="background: #2e61d7"
                    @click="addSave"
                    >保存</el-button
                >

                <el-button type="danger" size="small">删除</el-button>
                <el-button size="small" @click="handleClose">关闭</el-button>
            </div>
        </div>
    </div>
</template>

<script>
import otherRequest from '@/api/turnover/other.js'

export default {
    data () {
        return {
            //基础信息
            basicForm: {
                'baseCurId': '',
                'baseCurName': '',
                'baseCurNotTaxprice': 0,
                'baseCurRate': 0,
                'billId': '',
                'billNo': '',
                'changedDate': '',
                'changedDtlList': [
                    {
                        'changedDtlId': '',
                        'changedMoney': 0,
                        'changedPrice': 0,
                        'changedQuantity': 0,
                        'internalLeaseTransferDtlId': '',
                        'internalLeaseTransferId': '',
                        'materialCategoryId': '',
                        'materialCategoryName': '',
                        'materialId': '',
                        'materialName': '',
                        'money': 0,
                        'price': 0,
                        'quantity': 0,
                        'spec': '',
                        'texture': '',
                        'unit': ''
                    }
                ],
                'changedTotalMoney': 0,
                'currency': '',
                'currency_id': '',
                'nullifyCreated': '',
                'nullifyCreator': '',
                'nullifyCreatorId': '',
                'nullifyDescription': '',
                'nullifyReason': '',
                'operatorId': '',
                'operatorName': '',
                'taxRate': '',
                'taxAmount': '',
                'orgId': '',
                'orgName': '',
                'parentId': '',
                'parentNo': '',
                'period': 0,
                'receiverId': '',
                'receiverName': '',
                'remarks': '',
                'rmbId': '',
                'rmbName': '',
                'rmbNotTaxprice': 0,
                'rmbRate': 0,
                'state': 0,
                'totalMoney': 0,
                'transferInOrgId': '',
                'transferInOrgName': '',
                'workId': ''
            },
            formLabelWidth: '180px',
            currencyArr: [], //币种列表
            stateArr: ['草稿', '审核中', '已审核', '已作废'],
            yearNeedPlanList: []
        }
    },
    created () {
        this.billId = this.$route.query.billid
        this.getUserInfo()
        this.init()
    },

    methods: {
        init () {
            otherRequest.turnoverInternalLeaseTransferInit(this.billId).then(res=>{
                for (let key in res) {
                    this.basicForm[key] = res[key]
                }
            })
        },
        //获取本地登录信息
        getUserInfo () {
            const userInfo = JSON.parse(window.localStorage.getItem('vuex')).userInfo.orgInfo
            const userName = window.localStorage.getItem('userName')
            const userId = window.localStorage.getItem('userId')
            this.basicForm.handlerName = userName
            this.basicForm.handlerId = userId

            this.basicForm.orgId = userInfo.orgId
            this.basicForm.orgName = userInfo.orgName
        },
        //选择币种的事件
        changeCurrency () {
            const obj = this.currencyArr.find(item=>item.kvKey === this.basicForm.currency)
            this.basicForm.currencyId = obj.kvId
        },

        //基本信息保存
        addSave () {
            this.basicForm.parentId = this.billId

            this.$Ajax
                .httpPost({
                    url: '/turnover/internalLeaseTransferChanged/create',
                    params: this.basicForm
                })
                .then(() => {
                    this.clientPop('suc', '保存成功', this.handleClose)
                })
        },
        //取消
        handleClose () {
            this.$router.replace('/revolveInternalLeaseTransferList')
        }
    }
}
</script>

<style lang="scss" scoped>
.buttons {
    left: 0;
}
.e-form {
    padding: 0 20px;
    .tabs-title::before {
        content: '';
        height: 22px;
        width: 8px;
        border-radius: 40px;
        background-color: #2e61d7;
        display: block;
        position: absolute;
        left: 20px;
        margin-right: 20px;
    }
}
.e-table {
    min-height: auto;
    background: #fff;
}
.separ {
    width: 30px;
    height: 40px;
    line-height: 18px;
    text-align: center;
}
.upload {
    margin: 20px auto;
    display: flex;
    justify-content: center;
    text-align: center;
}

.upload-demo {
    display: flex;
    justify-content: center;
    align-items: center;
}

::v-deep.el-input--suffix .el-input__inner {
    padding-right: 5px;
}
::v-deep.el-table .cell {
    text-align: center;
}
</style>
